package ranab.unit;

/**
 * Power unit converter class.
 *
 * @author <a href="mailto:rana_b@yahoo.com">Rana Bhattacharyya</a>
 */
public 
class PowerUnit extends BaseUnit {
    
    private final static String[] UNITS = {
        "watt (W)", 
        "ft.lbf/s",    
        "kgf.m/s",   
        "horsepower (metric)", 
        "horsepower (hp)"     
    }; 
    
    // first convert it to watt (the base unit)
    private final static double[] WATT_TABLE = {
        1.0,
        0.7375,
        0.10197,
        0.13596e-2,
        0.13410e-2
    };
    
    /**
     * Get all the possible units.
     */
    public String[] getAllUnits() {
        return UNITS;
    }
    
    /**
     * Convert one unit from another
     */
    public String convertUnit(String value, int from, int to) throws UnitException {
        double inVal = getDoubleValue(value);
        double outVal = inVal*WATT_TABLE[to]/WATT_TABLE[from];
        return String.valueOf(outVal);
    }
    
    /**
     * Return unit type.
     */
    public String toString() {
        return "Power";
    }
    
}